home *** CD-ROM | disk | FTP | other *** search
/ Animation How-To / Animation How-to CD.iso / PLY / CHAPTER3 / CELL / HEXCELL1.BAS next >
BASIC Source File  |  1994-01-01  |  2KB  |  80 lines

  1. ' HEXCELL1.BAS
  2. OPEN "hexcell1.pi" FOR OUTPUT AS #1
  3.  
  4. PRINT #1, "// HEXCELL1.PI"
  5. PRINT #1, "// Growing Hexagonal Cluster that tumbles"
  6. PRINT #1,
  7. PRINT #1, "start_frame 1"
  8. PRINT #1, "end_frame 180"
  9. PRINT #1, "total_frames 180"
  10. PRINT #1,
  11. PRINT #1, "define index frame*360/total_frames"
  12. PRINT #1, "define size 12*frame/total_frames"
  13. PRINT #1, "define pi 3.14159"
  14. PRINT #1, "define rad pi/180"
  15. PRINT #1, "define tumble <index,45*sin(2*index*rad),90*cos(index*rad)>"
  16. PRINT #1,
  17. PRINT #1, "outfile "; CHR$(34); "hex"; CHR$(34)
  18. PRINT #1,
  19. PRINT #1, "include "; CHR$(34); "\ply\colors.inc"; CHR$(34)
  20. PRINT #1,
  21. PRINT #1, "viewpoint {"
  22. PRINT #1, "   from rotate(<15,35,-20>, tumble)/12*(size+1)"
  23. PRINT #1, "   at <0,0,0>"
  24. PRINT #1, "   up <0,1,0>"
  25. PRINT #1, "   angle 40"
  26. PRINT #1, "   resolution 320,200"
  27. PRINT #1, "   aspect 1.333"
  28. PRINT #1, "   }"
  29. PRINT #1,
  30. PRINT #1, "background MidnightBlue"
  31. PRINT #1,
  32. PRINT #1, "spot_light <1,0,0>, < 100,0,0>,<0,0,0>,3,5,20"
  33. PRINT #1, "spot_light <0,1,0>, <-100,0,0>,<0,0,0>,3,5,20"
  34. PRINT #1, "spot_light <0,0,1>, < 0, 100,0>,<0,0,0>,3,5,20"
  35. PRINT #1, "spot_light <1,1,0>, < 0,-100,0>,<0,0,0>,3,5,20"
  36. PRINT #1, "spot_light <0,1,1>, < 0,0, 100>,<0,0,0>,3,5,20"
  37. PRINT #1, "spot_light <1,0,1>, < 0,0,-100>,<0,0,0>,3,5,20"
  38. PRINT #1,
  39. PRINT #1, "define pop1 3*frame/30"
  40. PRINT #1, "define pop2 3*sin(3*frame*rad)"
  41. PRINT #1,
  42. PRINT #1, "if (frame < 30) {"
  43. PRINT #1, "   object { sphere <0,0,0>,pop1 matte_white }"
  44. PRINT #1, "}"
  45. PRINT #1,
  46. PRINT #1, "if (frame < 60) {"
  47. PRINT #1, "   object { sphere <0,0,0>,pop2 matte_white }"
  48. PRINT #1, "}"
  49. PRINT #1,
  50.  
  51. cel = 8
  52. n = 0
  53.  
  54. FOR z = -cel TO cel
  55.    z1 = z * 1.632993 + 0            ' sqrt(8/3)z
  56.    alt1 = 1
  57.    IF z MOD 2 = 0 THEN alt1 = 0
  58.  
  59.    FOR y = -cel TO cel
  60.       y1 = y * 1.732051 - 1.154701 * alt1   ' sqrt(3)y + 2*sqrt(3)/3
  61.       alt2 = 1
  62.       IF y MOD 2 = 0 THEN alt2 = 0
  63.  
  64.       FOR x = -cel TO cel
  65.          x1 = x * 2 + 1 * alt2         ' 2x + 1  or  2x + 0
  66.          IF (x1 ^ 2 + y1 ^ 2 + z1 ^ 2) ^ .5 < 12 THEN
  67.             vect$ = "c" + RIGHT$("0000" + LTRIM$(STR$(n)), 4)
  68.             PRINT #1, USING "define \    \ <###.#####,###.#####,###.#####>"; vect$; x1; y1; z1
  69.             PRINT #1, USING "if ( |\   \| < size) {"; vect$
  70.             PRINT #1, USING "   object { sphere \   \, 1  matte__white } "; vect$
  71.             PRINT #1, "}"
  72.             n = n + 1
  73.          END IF
  74.       NEXT x
  75.    NEXT y
  76. NEXT z
  77.  
  78. CLOSE #1
  79.  
  80.